import * as React from 'react';
import { useHistory } from './hooks';
import { parsePath } from './utils';

export const Link: React.FC<any> = ({to, children}: any) => {
  const history = useHistory();
  const goto = () => {
    const state = parsePath(to);
    history.push(to, state);
  };
  return (
    <div onClick={goto}>
      {children}
    </div>
  );  
};
